const {parseToken,generateToken}=require('../utils/tokenHandler')

class loginController{
    async login(ctx,next){
        let {id,name}=ctx.userInfo
        let token=generateToken({id,name})
        delete ctx.userInfo.password
        delete ctx.userInfo.createAt
        delete ctx.userInfo.updateAt
        ctx.userInfo.token='Besc '+token
        ctx.mesg='登录成功'
        ctx.body=ctx.userInfo
        await next()
    }
}

module.exports=new loginController()